const path = require('path')
// const Mock = require('./mock-server/index')

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    publicPath: process.env.NODE_ENV === 'production' ?
        // '' : '', //用mockjs 置空参数
        '/nanospr/ration' : '/api/nanospr/ration',
    devServer: {
        disableHostCheck: false, // 禁用webpack热重载检查 解决热更新失效问题
        proxy: {
            '/api': {
                target: 'http://47.103.51.14:8804/',
                changeOrigin: true,
                secure: true, //https需要增加 表示是否校验证书
                ws: true,
                pathRewrite: {
                    '^/api': ''
                }
            }
        },
        // before(app) {
        //     Mock(app)
        // }

    },
    css: {
        loaderOptions: {
            less: {
                javascriptEnabled: true
            }
        }
    },
    //引入svg配置
    chainWebpack: config => {
        config.module
            .rule('svg')
            .exclude.add(resolve('src/icons'))
            .end();
        config.module
            .rule('icons')
            .test(/\.svg$/)
            .include.add(resolve('src/icons'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: 'icon-[name]'
            });
    },
    indexPath: path.resolve(__dirname, './ration/index.html'),
    outputDir: path.resolve(__dirname, './ration'),
    assetsDir: 'asset',
    filenameHashing: true,
    // 生产环境 sourceMap
    productionSourceMap: false,
    lintOnSave: false
}